{extend name="/fool" /}
{block name="css"}
<link rel="stylesheet" href="/css/admin/user_setting.css">
<style>
    .last{
        text-align: left;
    }
    .tjck{
        background: #fff;
        box-shadow: 0 0 10px 0 rgba(0,0,0,0.5);
        width:300px;
        position: absolute;
        left:50%;
        top:50%;
        margin-top: -300px;
        margin-left: -150px;
        display: none;
    }
    .zilan{
        margin-left: 50px;
    }
</style>
{/block}
{block name="menu_content"}
    <div class="tjck">
        <form class="layui-form" action="" method="post">
            <ul style="padding:20px 0 0 20px;">
                {foreach $all as $k=>$v}
                <li class="lan">
                    <input type="hidden" name="qx" value="1">
                    {if $v['pid']}
                    {if $v.checked == 1}
                    <div><input class="one{$k}" type="checkbox" name="id[{$v.id}]" title="{$v.name}" checked>{$v.id}</div>
                    {else}
                    <div><input class="one{$k}" type="checkbox" name="id[{$v.id}]" title="{$v.name}">{$v.id}</div>
                    {/if}
                    <ul>
                        {foreach $v.pid as $kk=>$vv}
                        {if $vv.checked == 1}
                        <li class="zilan"><input class="two{$k}" type="checkbox" name="id[{$vv.id}]" title="{$vv.name}" checked>{$vv.id}</li>
                        {else}
                        <li class="zilan"><input class="two{$k}" type="checkbox" name="id[{$vv.id}]" title="{$vv.name}">{$vv.id}</li>
                        {/if}
                        {/foreach}
                    </ul>
                </li>
                {else}
                {if $v.checked == 1}
                <li><input type="checkbox" name="id[{$v.id}]" title="{$v.name}" checked>{$v.id}</li>
                {else}
                <li><input type="checkbox" name="id[{$v.id}]" title="{$v.name}">{$v.id}</li>
                {/if}
                {/if}
                {/foreach}
            </ul>
            <div style="text-align: center;margin-top: 30px;padding-bottom: 30px;">
                <button type="button" class="qx layui-btn layui-btn-normal">取消</button>
                <button type="submit" class="saves layui-btn layui-btn-normal">保存</button>
            </div>
        </form>
    </div>
<div>
    <form class="layui-form" action="" method="post">
        <table>
            <tr>
                <td>使用人：</td>
                <td class="last">
                    <div class="layui-input-inline">
                        <input id="name" value="{$user['name']}" type="text" name="name" autocomplete="off" class="layui-input" placeholder="使用人">
                    </div>
                </td>
            </tr>
            <tr>
                <td>账号：</td>
                <td class="last">
                    <div class="layui-input-inline">
                        <input id="username" value="{$user['username']}" type="text" name="username" autocomplete="off" class="layui-input" placeholder="账号">
                    </div>
                </td>
            </tr>
            <tr>
                <td>密码：</td>
                <td class="last">
                    <div class="layui-input-inline">
                        <input id="password" type="password" name="password" autocomplete="off" class="layui-input" placeholder="密码">
                    </div>
                </td>
            </tr>
            {if $login['admin'] == 1}
            <tr>
                <td>后台操作权限：</td>
                <td class="last">
                    <div class="layui-input-inline">
                    <select name="admin">
                    	{if $user['admin'] == 1}
                        <option value="1" selected>有</option>
                        <option value="2">无</option>
                        {else}
                        <option value="1">有</option>
                        <option value="2" selected>无</option>
                        {/if}
                    </select>
                </div>
                </td>
            </tr>
            {/if}
            <tr>
                <td>开放区域：</td>
                <td class="last">
                    <button type="button" class="add layui-btn layui-btn-normal">添加</button>
                </td>
            </tr>
            <tr>
                <td></td>
                <td class="last">
                    <button type="submit" class="save layui-btn layui-btn-normal">保存</button>
                </td>
            </tr>
        </table>
    </form>
</div>
<script>
    $(".save").click(function(){
        var name = $('#name').val();
        var username = $("#username").val();
        var password = $("#password").val();
        console.log(password);
        $.post("{:url('setting')}",{
            name,username,password
        },function(res){console.log(res)},'json');
    })
    $(".saves").click(function(){
        history.go(0);
    })
    $(".add").click(function(){
        $(".tjck").show();
    })
    $(".qx").click(function(){
        $(".tjck").hide();
    })
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });

    "{if isset($success)}"
    layui.use('layer', function(){
        var layer = layui.layer;

        layer.msg("{$success}");
    });
    "{/if}"
</script>
{/block}